<?php
include '../../../wp-blog-header.php';
require_once('rss_fetch.inc');
$url = 'http://www.taggle.com/offers/rss/all/';
exit();
$rss = fetch_rss($url);

echo '<pre>';
print_r($rss->items);
//exit();

foreach($rss->items as $key=>$value)
{
$columns_deal['name'] = pods_sanitize(ucwords(strtolower($value['title'])));
$columns_deal['camp_link'] = sanitize_title($columns_deal['name']);

$Record = new Pod('deal');
$where = 'camp_link = "'.$columns_deal['camp_link'].'"';
$Record->findRecords('id DESC', -1,$where);
$dealsFound = $Record->getTotalRows();
echo $dealsFound."<br />";
if($dealsFound == 0)
{
  $City = new Pod('city');
	$City->findRecords('id ASC');
	$i = 0;
	unset($ids);
	unset($current_cities);
  while($City->fetchRecord())
	{
  	$ids  = $City->get_field('id');
  	$current_cities[$i]= $ids;
  	$i++;
	}
  $current_cities = implode(',',$current_cities);
  $columns_deal['city'] = $current_cities;
  $columns_deal['brand'] = '275';
  $columns_deal['extlink'] = make_bitly_url($value['link'].'?afCode=3XR5MA'); 
  $columns_deal['camp_end'] = date('Y-m-d H:i:s',strtotime('+1 day',strtotime(date("Y-m-d 12:00:00"))));
  $columns_deal['camp_start'] = date('Y-m-d H:i:s');
  $columns_deal['daily'] = '1';
  preg_match_all('#<\s*img [^\>]*src\s*=\s*(["\'])(.*?)\1#im',$rss->items[$key][description], $matches_img); 
  
  $columns_deal['ext_image_url'] = 'http://taggle.com'.$matches_img[2][0];
  $api = new PodAPI();
  $params = array('datatype' => 'deal', 'columns' => $columns_deal);
  echo "<pre>";
  print_r($params);
  
  //exit();
  
  $api->save_pod_item($params);
}
}
?>